#!/bin/bash

set -e

if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
         "Usage: $(basename "$0")
Publish docker GPU container to ECR.
"
}

PROJECT_ROOT="$(dirname "$(dirname "$(readlink -f "${0}")")")"

if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
    if [ "${1:-}" = "--help" ]
    then
        usage
    else
        $PROJECT_ROOT/scripts/update
        `aws ecr get-login --region us-east-1`
        docker tag raster-vision-gpu:latest 279682201306.dkr.ecr.us-east-1.amazonaws.com/raster-vision-gpu:latest
        docker push 279682201306.dkr.ecr.us-east-1.amazonaws.com/raster-vision-gpu:latest

        docker tag raster-vision-gpu:latest 279682201306.dkr.ecr.us-east-1.amazonaws.com/raster-vision-cpu:latest
        docker push 279682201306.dkr.ecr.us-east-1.amazonaws.com/raster-vision-cpu:latest
    fi
fi
